/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Andriy
 */
@Entity
@Table(name = "WAREHOUSE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Warehouse.findAll", query = "SELECT w FROM Warehouse w"),
    @NamedQuery(name = "Warehouse.findByName", query = "SELECT w FROM Warehouse w WHERE w.name = :name"),
    @NamedQuery(name = "Warehouse.findByAddress", query = "SELECT w FROM Warehouse w WHERE w.address = :address"),
    @NamedQuery(name = "Warehouse.findByIdWarehouse", query = "SELECT w FROM Warehouse w WHERE w.idWarehouse = :idWarehouse"),
    @NamedQuery(name = "Warehouse.findByDurationKoefficient", query = "SELECT w FROM Warehouse w WHERE w.durationKoefficient = :durationKoefficient"),
    @NamedQuery(name = "Warehouse.findByShipmentRate", query = "SELECT w FROM Warehouse w WHERE w.shipmentRate = :shipmentRate")})
public class Warehouse implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 150)
    @Column(name = "ADDRESS")
    private String address;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_WAREHOUSE")
    private Integer idWarehouse;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "DURATION_KOEFFICIENT")
    private BigDecimal durationKoefficient;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SHIPMENT_RATE")
    private BigDecimal shipmentRate;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idWarehouse")
    private Collection<Orders> ordersCollection;

    public Warehouse() {
    }

    public Warehouse(Integer idWarehouse) {
        this.idWarehouse = idWarehouse;
    }

    public Warehouse(Integer idWarehouse, String name, String address, BigDecimal durationKoefficient, BigDecimal shipmentRate) {
        this.idWarehouse = idWarehouse;
        this.name = name;
        this.address = address;
        this.durationKoefficient = durationKoefficient;
        this.shipmentRate = shipmentRate;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Integer getIdWarehouse() {
        return idWarehouse;
    }

    public void setIdWarehouse(Integer idWarehouse) {
        this.idWarehouse = idWarehouse;
    }

    public BigDecimal getDurationKoefficient() {
        return durationKoefficient;
    }

    public void setDurationKoefficient(BigDecimal durationKoefficient) {
        this.durationKoefficient = durationKoefficient;
    }

    public BigDecimal getShipmentRate() {
        return shipmentRate;
    }

    public void setShipmentRate(BigDecimal shipmentRate) {
        this.shipmentRate = shipmentRate;
    }

    @XmlTransient
    public Collection<Orders> getOrdersCollection() {
        return ordersCollection;
    }

    public void setOrdersCollection(Collection<Orders> ordersCollection) {
        this.ordersCollection = ordersCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idWarehouse != null ? idWarehouse.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Warehouse)) {
            return false;
        }
        Warehouse other = (Warehouse) object;
        if ((this.idWarehouse == null && other.idWarehouse != null) || (this.idWarehouse != null && !this.idWarehouse.equals(other.idWarehouse))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Warehouse[ idWarehouse=" + idWarehouse + " ]";
    }
    
}
